1. Field of the Invention
The present invention relates generally to computer usable program code optimization and more particularly to a computer implemented method, a data processing system and a computer program product for optimizing computer usable program code containing multiple reader locks having at least one non-reader lock therein.
2. Description of the Related Art
Multiple reader locks are used to improve the performance of synchronized, multi-threaded programs by allowing many threads to enter critical sections if only variable reads will be performed. Once a thread obtains a lock to do a write, all other threads that might access the critical section must wait for the single writer to finish before being able to proceed. To transform a particular critical section to use a multiple-reader lock, the programmer or compiler must verify that no variable writes occur inside. If any writes occur, then a writer lock must be used which will slow down all other threads. This requirement is needed even if the critical section only writes to variables on some paths of execution, but not on others, even if those paths where the writes occur are only rarely executed. Since write locks force all threads to wait until the writer access is complete, performance can suffer markedly, even if the thread making the write access does not actually write to any variable.